<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/manage/header.jsp"%>
<div>
    <c:if test="${empty page.records}">
    	<h2>没有任何书籍，请先添加</h2>
    	<a href="${pageContext.request.contextPath}/manage/ManageServlet?op=addBookUI">添加书籍</a>
    </c:if>
     <c:if test="${!empty page.records}">
    	<table border="1" width="800">
    		<tr>
    			<th>图片</th>
    			<th>书名</th>
    			<th>数量</th>
    			<th>作者</th>
    			<th>单价</th>
    			<th>描述</th>
    			<th>所属分类</th>
    			<th>操作</th>
    		</tr>
    		<c:forEach items="${page.records}" var="b" varStatus="vs">
    		 	<tr class="odd">
	    			<td align="center">
	    				<img src="${pageContext.request.contextPath}/images/${b.path}/${b.filename}"  width="87"  height="117"/>
	    			</td>
	    			<td>${b.name}</td>
	    			<td>${b.total}本</td>
	    			<td>${b.author }</td>
	    			<td>${b.price }￥</td>
	    			<td>${b.description }</td>
	    			<td>${b.category.name }</td>
	    			<td>
	    			    [<a href="${pageContext.request.contextPath}/manage/ManageServlet?op=addBookUI">添加</a>]
	    				[<a href="javascript:updateOneItem('${b.id}')">修改</a>]
	    				[<a href="javascript:delOneItem('${b.id}')">删除</a>]
	    			</td>
	    		</tr>
    		</c:forEach>
    	</table>
    	<%@include file="/commons/page.jsp"%>
    	
    </c:if>
    </div>
    <script type="text/javascript">
	function delOneItem(bookId) {
		var sure = window.confirm("确定删除该选项？");
		if (sure) {
			window.location.href = "${pageContext.request.contextPath}/manage/ManageServlet?op=deleBook&bookId="+ bookId;
		}
	}
	function updateOneItem(bookId) {
		var sure = window.confirm("确定修改？");
		if (sure) {
			window.location.href = "${pageContext.request.contextPath}/manage/ManageServlet?op=updateBook&bookId="+ bookId;
		}
	}
</script>
  </body>
</html>
